import fs from 'fs'
import path from 'path'

/**
 * @param {string} name 图标名称
 */
function toMultiName(name) {
  if (name.includes('&')) {
    return name.replace('&', 'x')
  }
  const size = name.replace('.png', '').split('-')[1]
  const toName = `${size}x${size}.png`
  return toName
}

/**
 * @param {string} name 图标名称
 */
function isFavicon(name) {
  return name.includes('favicon-') || name.includes('&')
}

const iconsDir = path.join(__dirname, 'resources', 'icons')
fs.readdirSync(iconsDir).forEach((name) => {
  if (isFavicon(name)) {
    const toName = toMultiName(name)
    fs.renameSync(path.join(iconsDir, name), path.join(iconsDir, toName))
  }
})
